#ifndef LINKLIST_H
#define LINKLIST_H

#include <malloc.h>

#define MAX_SORTKEYS			10

typedef struct tagListSortInfo
{
	BOOL Ascending;
	int NumKeys;
	struct LISTSORTKEY
	{
		int Offset;
		int Type; 
		int DataType;  //string, number or date
	} Key[MAX_SORTKEYS];
} LISTSORTINFO, FAR *LPLISTSORTINFO;

enum elistSortType
{
	estString,
	estInt,
	estDateStr,
	estDateDword,
	estLPSZ,
	estlpDateStr,
	estdwStatus
};

typedef struct tagListItem
{
	void FAR *lpPrevItem;
	void FAR *lpNextItem;
	void FAR *lpItem;
} LISTITEM, FAR *LPLISTITEM;

typedef struct tagListHeader
{
	LPLISTITEM lpFirstItem;
	LPLISTITEM lpLastItem;
	int iNumItems;   
//	int eSortedBy;
//	BOOL bAscending;      
	LISTSORTINFO SortInfo;
} LISTHEADER, FAR *LPLISTHEADER;

typedef HGLOBAL HLIST;

#if defined( __cplusplus )
extern "C" {
#endif

HLIST WINAPI ListCreate(void);
BOOL WINAPI ListDestroy(HLIST);
BOOL WINAPI ListAddTail(HLIST, void FAR *);
LPLISTITEM WINAPI ListGetHead(HLIST);
LPLISTITEM WINAPI ListGetTail(HLIST);
void FAR * WINAPI ListGetNext(HLIST, LPLISTITEM FAR *);
void FAR * WINAPI ListGetPrev(HLIST, LPLISTITEM FAR *);
BOOL WINAPI ListDelete(HLIST);
BOOL WINAPI ListSort(HLIST, LPLISTSORTINFO);
void FAR * WINAPI ListMalloc(size_t);
void WINAPI ListFree(void FAR *);
int WINAPI ListGetNumItems(HLIST);
void WINAPI ListDeleteItem(HLIST, LPLISTITEM);
void WINAPI ListRemoveItem(HLIST, LPLISTITEM);
int WINAPI ListGetSortedBy(HLIST);
BOOL WINAPI ListSortedAscending(HLIST);
void WINAPI ListGetSortInfo(HLIST, LPLISTSORTINFO);

#if defined( __cplusplus )
}
#endif

#endif //LINKLIST_H